package com.aloha.common.aop;

import com.aloha.springframework.stereotype.Component;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;

/**
 * @author DaiZhiHeng
 * @date 2023/8/3 13:00
 */
@Slf4j
@Aspect
@Component
public class LogAspect {

    @Around("@annotation(com.aloha.common.aop.SysLog)")
    public Object doLog(ProceedingJoinPoint joinPoint) throws Throwable {
        Object arg = joinPoint.getArgs()[0];
        log.info("请求参数：{}", arg);
        Object result = joinPoint.proceed();
        log.info("响应结果：{}", result);
        return result;
    }

}
